package cn.lili.modules.promotion.serviceimpl;

import cn.lili.modules.promotion.entity.dos.TicketCanvas;
import cn.lili.modules.promotion.mapper.TicketCanvasMapper;
import cn.lili.modules.promotion.service.TicketCanvasService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class TicketCanvasServiceImpl extends ServiceImpl<TicketCanvasMapper, TicketCanvas>
        implements TicketCanvasService {

    /**
     * 根据区域获取画布
     * @param areaId
     * @param areaDirection
     * @return
     */
    @Override
    public TicketCanvas getByArea (String areaId, String areaDirection) {
        LambdaQueryWrapper<TicketCanvas> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TicketCanvas::getAreaId, areaId);
        queryWrapper.eq(TicketCanvas::getAreaDirection, areaDirection);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }

    /**
     * 根据区域获取画布
     * @param areaName
     * @param areaDirection
     * @return
     */
    @Override
    public TicketCanvas getByAreaName (String areaName, String areaDirection) {
        LambdaQueryWrapper<TicketCanvas> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TicketCanvas::getAreaName, areaName);
        queryWrapper.eq(TicketCanvas::getAreaDirection, areaDirection);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
